package com.sx.gongzhong.pest;

import android.content.Context;

import com.sx.gongzhong.model.HeadParamBean;
import com.sx.gongzhong.model.HelpBean;
import com.sx.gongzhong.model.ReplyUserBean;
import com.sx.gongzhong.net.BaseCallBack;
import com.sx.gongzhong.model.BasePageListBean;
import com.sx.gongzhong.net.HelpManager;
import com.sx.gongzhong.view.HelpListView;

import java.util.Map;

/**互帮互助 列表
 * Created by admin on 2018/1/12.
 */

public class HelpListPest {
    private HelpListView helpListView;

    public HelpListPest(HelpListView helpListView) {
        this.helpListView = helpListView;
    }

    public void getHelpListData(Context context, int page, int rows) {
        Map<String,Object> map = HeadParamBean.getHead();
        map.put("sourcesState",0);
        map.put("page",page);
        map.put("rows",rows);
        new HelpManager().getHelpListData(map, new BaseCallBack<ReplyUserBean.BaseResult<BasePageListBean<HelpBean>>>() {
            @Override
            public void onSuccess(ReplyUserBean.BaseResult<BasePageListBean<HelpBean>> response) {
                helpListView.getSuccess(response.data.rows,response.data.total);
            }
            @Override
            public void onFailures(String message) {
                helpListView.showError(message);
            }
        });
    }

    public void getMyHelpListData(Context context, int page, int rows) {
        Map<String,Object> map = HeadParamBean.getHead();
        map.put("page",page);
        map.put("rows",rows);
        new HelpManager().getMyHelpListData(map, new BaseCallBack<ReplyUserBean.BaseResult<BasePageListBean<HelpBean>>>() {
            @Override
            public void onSuccess(ReplyUserBean.BaseResult<BasePageListBean<HelpBean>> response) {
                helpListView.getSuccess(response.data.rows,response.data.total);
            }
            @Override
            public void onFailures(String message) {
                helpListView.showError(message);
            }
        });
    }
}
